load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "lightning",
    srcs = [
        "lightning.go",
        "run_options.go",
        "sigusr1_other.go",
        "sigusr1_unix.go",
    ],
    importpath = "github.com/pingcap/tidb/br/pkg/lightning",
    visibility = ["//visibility:public"],
    deps = [
        "//br/pkg/lightning/backend/local",
        "//br/pkg/lightning/checkpoints",
        "//br/pkg/lightning/common",
        "//br/pkg/lightning/config",
        "//br/pkg/lightning/importer",
        "//br/pkg/lightning/log",
        "//br/pkg/lightning/metric",
        "//br/pkg/lightning/mydump",
        "//br/pkg/lightning/tikv",
        "//br/pkg/lightning/web",
        "//br/pkg/redact",
        "//br/pkg/restore/split",
        "//br/pkg/storage",
        "//br/pkg/utils",
        "//br/pkg/version/build",
        "//pkg/expression",
        "//pkg/planner/core",
        "//pkg/util",
        "//pkg/util/promutil",
        "@com_github_go_sql_driver_mysql//:mysql",
        "@com_github_google_uuid//:uuid",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_kvproto//pkg/import_sstpb",
        "@com_github_prometheus_client_golang//prometheus",
        "@com_github_prometheus_client_golang//prometheus/collectors",
        "@com_github_prometheus_client_golang//prometheus/promhttp",
        "@com_github_shurcool_httpgzip//:httpgzip",
        "@org_uber_go_atomic//:atomic",
        "@org_uber_go_zap//:zap",
        "@org_uber_go_zap//zapcore",
    ],
)

go_test(
    name = "lightning_test",
    timeout = "short",
    srcs = [
        "lightning_serial_test.go",
        "lightning_server_serial_test.go",
        "main_test.go",
    ],
    embed = [":lightning"],
    flaky = True,
    shard_count = 7,
    deps = [
        "//br/pkg/lightning/checkpoints",
        "//br/pkg/lightning/config",
        "//br/pkg/lightning/log",
        "//br/pkg/lightning/mydump",
        "//br/pkg/lightning/web",
        "@com_github_data_dog_go_sqlmock//:go-sqlmock",
        "@com_github_docker_go_units//:go-units",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_stretchr_testify//require",
    ],
)
